//////////////////////////////////////////////////////////////////////////

#ifndef _CONNECTMENU_H_
#include "connectmenu.h"
#endif

//////////////////////////////////////////////////////////////////////////

#ifndef _CONTROL_H_
#include "control.h"
#endif

#ifndef _BUTTON_H_
#include "button.h"
#endif

#ifndef _EDIT_H_
#include "edit.h"
#endif

#ifndef _SURFACE_H_
#include "surface.h"
#endif

//////////////////////////////////////////////////////////////////////////


GUI_ConnectMenu::GUI_ConnectMenu()
{
    m_Buffer = 0;
    m_Controls.resize(GUI_ConnectMenu::ButtonCount);
    m_Labels.resize(GUI_ConnectMenu::LabelCount);
    m_FocusedControl = -1;

    m_Labels[GUI_ConnectMenu::ConnectLabel] = new GUI_Button(GUI_Images::Empty, GUI_Fonts::CaptionText, GUI_Colors::ButtonText, "Connect", GUI_Images::Empty, 0.1f, 0.3f, GUI_Surface::AllignLeft, 0.01f, 0.0f);

    m_Labels[GUI_ConnectMenu::ServerAddressLabel] = new GUI_Button(GUI_Images::Empty, GUI_Fonts::ButtonText, GUI_Colors::ButtonText, "ServerAddress", GUI_Images::Empty, 0.1f, 0.5f, GUI_Surface::AllignLeft, 0.01f, 0.0f);
    m_Controls[GUI_ConnectMenu::ServerAddress] = new GUI_Edit(GUI_Images::Edit, GUI_Fonts::EditText, GUI_Colors::EditText, "localhost", GUI_Images::EditHover, 0.5f, 0.5f);

    m_Labels[GUI_ConnectMenu::UserNameLabel] = new GUI_Button(GUI_Images::Empty, GUI_Fonts::ButtonText, GUI_Colors::ButtonText, "User Name", GUI_Images::Empty, 0.1f, 0.6f, GUI_Surface::AllignLeft, 0.01f, 0.0f);
    m_Controls[GUI_ConnectMenu::UserName] = new GUI_Edit(GUI_Images::Edit, GUI_Fonts::EditText, GUI_Colors::EditText, "Noname", GUI_Images::EditHover, 0.5f, 0.6f);

    m_Controls[GUI_ConnectMenu::Connect] = new GUI_Button(GUI_Images::ButtonGreen, GUI_Fonts::ButtonText, GUI_Colors::ButtonText, "Connect", GUI_Images::ButtonGreenHover, 0.2f, 0.7f);
    m_Controls[GUI_ConnectMenu::Cancel] = new GUI_Button(GUI_Images::ButtonRed, GUI_Fonts::ButtonText, GUI_Colors::ButtonText, "Canel", GUI_Images::ButtonRedHover, 0.2f, 0.8f);

}


//////////////////////////////////////////////////////////////////////////


const std::string& GUI_ConnectMenu::GetControlValue(Button _name)
{
    return ((GUI_Edit *)m_Controls[_name])->GetText();
}


//////////////////////////////////////////////////////////////////////////


GUI_ConnectMenu::~GUI_ConnectMenu()
{
    for (int i = 0; i < m_Controls.size(); ++i)
        delete m_Controls[i];
    for (int i = 0; i < m_Labels.size(); ++i)
        delete m_Labels[i];
}


//////////////////////////////////////////////////////////////////////////
